package com.lagou;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author shize
 */
public class Generate {

    public static void main(String[] args) {
        List<List<Integer>> balls = new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            List<Integer> oneShot = generatedOneShot();
            balls.add(oneShot);
        }

        balls.forEach(System.out::println);
    }

    private static List<Integer> generatedOneShot() {
        List<Integer> oneShot = new ArrayList<>();

        List<Integer> newList = getRedNewList();
        // six red ball
        for (int i = 0; i <= 5; i++) {
            int oneNum = generatedOneNum(newList);
            oneShot.add(oneNum);
        }

        oneShot = oneShot.stream().sorted(Comparator.comparingInt(Integer::intValue)).collect(Collectors.toList());

        int oneNum = generatedOneNum(getBlueNewList());
        oneShot.add(oneNum);

        return oneShot;
    }

    private static int generatedOneNum(List<Integer> collect) {
        int a = new Random().nextInt(33) + 1;
        if (collect.contains(a)) {
            collect.remove(Integer.valueOf(a));
            return a;
        }

        return generatedOneNum(collect);
    }

    static List<Integer> getRedNewList() {
        return Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33)
                .collect(Collectors.toList());
    }

    static List<Integer> getBlueNewList() {
        return Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
                .collect(Collectors.toList());
    }
}
